package com.ricchieri.manage.bean;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import com.ricchieri.bean.TravelStatusBean;
import com.ricchieri.common.BusinessSettings;
import com.ricchieri.model.ScheduleCharter;
import com.ricchieri.util.FacesUtil;

@ManagedBean(name = "viewTravelStatusMB")
@ViewScoped
public class ViewTravelStatusManageBean extends GenericManageBean {

	private static final long serialVersionUID = -4431457088573798836L;
	
	private TravelStatusBean travelStatusBean;
	
	@PostConstruct
	public void init() {
		ScheduleCharter scheduleCharter = (ScheduleCharter) FacesUtil.getParametersFlash(BusinessSettings.KEY_SCHEDULE_CHARTER);
		if(scheduleCharter != null) {
			travelStatusBean = new TravelStatusBean(scheduleCharter, scheduleCharter.getScheduleCharterExpense());
		} else {
			FacesUtil.redirectToNavigationCase(BusinessSettings.TRAVEL_STATUS);
		}
	}

	public TravelStatusBean getTravelStatusBean() {
		return travelStatusBean;
	}

	public void setTravelStatusBean(TravelStatusBean travelStatusBean) {
		this.travelStatusBean = travelStatusBean;
	}
}
